from Base import GetYamlFile
import os

from Base.ReadExcel import Read_Excel

#获取爬虫链接&项目
def get_serch_test_case():
    list1=[]
    YmlList=GetYamlFile.getYamlFile()
    TestCase=YmlList["SearchTestCase"]
    gettestpath=GetYamlFile.getBugPath("TestPath")
    readBook = Read_Excel(gettestpath)
    allNum =readBook.get_RowNums(TestCase)
    # print(allNum)
    for itemNum in range(1,allNum):
            #获取项目名称
            testName =readBook.read_Excel(TestCase,itemNum,0)
            title = readBook.read_Excel(TestCase,itemNum,1)
            number = readBook.read_Excel(TestCase,itemNum,2)
            type = readBook.read_Excel(TestCase,itemNum,3)
            url = readBook.read_Excel(TestCase,itemNum,4)
            testCase={
                "title":title,
                "number":number,
                "type":type,
                "url":url
            }
            items=(testName,testCase)
            # print(items)
            list1.append(items)
    # print(list1)
    return list1
def get_test_case():
    list1 = []
    YmlList = GetYamlFile.getYamlFile()
    TestPath = YmlList["TestPath"]
    TestCase = YmlList["TestCase"]
    PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
    REPORT_XLSX_DIR = os.path.join(PROJECT_ROOT, TestPath)
    readBook = Read_Excel(REPORT_XLSX_DIR)
    allNum = readBook.get_RowNums(TestCase)
    for itemNum in range(1, allNum):
        # 获取项目名称
        testName = readBook.read_Excel(TestCase, itemNum, 0)
        title = readBook.read_Excel(TestCase, itemNum, 1)
        url = readBook.read_Excel(TestCase, itemNum, 2)
        testCase = {
            "title": title,
            "url": url
        }
        items = [testName, testCase]
        # print(items)
        list1.append(items)
    # print(list1)
    return list1
def get_unresolved_bugs_case():
    list1 = []
    YmlList = GetYamlFile.getYamlFile()
    TestPath = YmlList["TestPath"]
    TestCase = YmlList["unresolvedBugsCase"]
    PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
    REPORT_XLSX_DIR = os.path.join(PROJECT_ROOT, TestPath)
    readBook = Read_Excel(REPORT_XLSX_DIR)
    allNum = readBook.get_RowNums(TestCase)
    for itemNum in range(1, allNum):
        # 获取项目名称
        testName = readBook.read_Excel(TestCase, itemNum, 0)
        title = readBook.read_Excel(TestCase, itemNum, 1)
        url = readBook.read_Excel(TestCase, itemNum, 2)
        testCase = {
            "title": title,
            "url": url
        }
        items = [testName, testCase]
        # print(items)
        list1.append(items)
    # print(list1)
    return list1
if __name__ == '__main__':
    get_unresolved_bugs_case()